package com.xc.hotelmgr.webapi.modules.ht.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xc.hotelmgr.webapi.modules.dt.entity.DtEntity;
import com.xc.hotelmgr.webapi.modules.dt.entity.StoreEntity;
import com.xc.hotelmgr.webapi.modules.dt.entity.StorePfEntity;
import com.xc.hotelmgr.webapi.modules.dt.service.DtService;
import com.xc.hotelmgr.webapi.modules.dt.service.StorePfService;
import com.xc.hotelmgr.webapi.modules.dt.service.StoreService;
import com.xc.hotelmgr.webapi.modules.ht.entity.HtBrandEntity;
import com.xc.hotelmgr.webapi.modules.ht.entity.HtCityinfoEntity;
import com.xc.hotelmgr.webapi.modules.ht.entity.HtTypeEntity;
import com.xc.hotelmgr.webapi.modules.ht.service.HtBrandService;
import com.xc.hotelmgr.webapi.modules.ht.service.HtCityinfoService;
import com.xc.hotelmgr.webapi.modules.ht.service.HtTypeService;
import com.xc.hotelmgr.webapi.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xc.hotelmgr.webapi.modules.ht.entity.HtHotelinfoEntity;
import com.xc.hotelmgr.webapi.modules.ht.service.HtHotelinfoService;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.R;



/**
 * 
 *
 * @author kemmy
 * @email kemmy@gmail.com
 * @date 2020-09-17 15:41:06
 */
@RestController
@RequestMapping("ht/hthotelinfo")
public class HtHotelinfoController extends AbstractController {
    @Autowired
    private HtHotelinfoService htHotelinfoService;

    @Autowired
    private HtCityinfoService htCityinfoService;

    @Autowired
    private HtBrandService htBrandService;

    @Autowired
    private HtTypeService htTypeService;

    /**
     * 查询城市信息下拉列表
     */
    @RequestMapping("/citys")
    @RequiresPermissions("ht:hthotelinfo:list")
    public R data(@RequestParam Map<String, Object> params){
        List<HtCityinfoEntity> list = htCityinfoService.queryData(params);
        return R.ok().put("list", list);
    }

    /**
     * 查询酒店品牌
     */
    @RequestMapping("/brand")
    @RequiresPermissions("ht:hthotelinfo:list")
    public R listBrand(){
        List<HtBrandEntity> list = htBrandService.getBaseMapper().selectList(new QueryWrapper<HtBrandEntity>());
        return R.ok().put("list", list);
    }

    /**
     * 查询酒店类型下拉列表
     */
    @RequestMapping("/httype")
    @RequiresPermissions("ht:hthotelinfo:list")
    public R listHtType() {
        List<HtTypeEntity> list = htTypeService.getBaseMapper().selectList(new QueryWrapper<HtTypeEntity>());
        return R.ok().put("list", list);
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("ht:hthotelinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = htHotelinfoService.sqlQueryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("ht:hthotelinfo:info")
    public R info(@PathVariable("id") Integer id){
		//HtHotelinfoEntity htHotelinfo = htHotelinfoService.getById(id);
        HtHotelinfoEntity htHotelinfo = htHotelinfoService.getWDById(id);
        return R.ok().put("htHotelinfo", htHotelinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("ht:hthotelinfo:save")
    public R save(@RequestBody HtHotelinfoEntity htHotelinfo){
		htHotelinfoService.save(htHotelinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("ht:hthotelinfo:update")
    public R update(@RequestBody HtHotelinfoEntity htHotelinfo){
		htHotelinfoService.updateById(htHotelinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ht:hthotelinfo:delete")
    public R delete(@RequestBody Integer[] ids){
		htHotelinfoService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
